"""HTTP状态码常量"""

# 成功响应状态码
HTTP_200_OK = 200
HTTP_201_CREATED = 201
HTTP_204_NO_CONTENT = 204

# 客户端错误状态码
HTTP_400_BAD_REQUEST = 400
HTTP_401_UNAUTHORIZED = 401
HTTP_403_FORBIDDEN = 403
HTTP_404_NOT_FOUND = 404
HTTP_409_CONFLICT = 409
HTTP_422_UNPROCESSABLE_ENTITY = 422
HTTP_429_TOO_MANY_REQUESTS = 429

# 服务器错误状态码
HTTP_500_INTERNAL_SERVER_ERROR = 500
HTTP_502_BAD_GATEWAY = 502
HTTP_503_SERVICE_UNAVAILABLE = 503

# 业务状态码
class BusinessCode:
    """业务状态码"""
    
    # 通用状态码
    SUCCESS = 10000              # 操作成功
    PARAM_ERROR = 10001          # 参数错误
    DATA_NOT_FOUND = 10002       # 数据不存在
    DATA_ALREADY_EXISTS = 10003  # 数据已存在
    OPERATION_FAILED = 10004     # 操作失败
    
    # 认证相关状态码 (20xxx)
    USER_NOT_LOGIN = 20001       # 用户未登录
    PERMISSION_DENIED = 20002    # 权限不足
    TOKEN_EXPIRED = 20003        # 令牌过期
    TOKEN_INVALID = 20004        # 令牌无效
    LOGIN_FAILED = 20005         # 登录失败
    PASSWORD_ERROR = 20006       # 密码错误
    USER_DISABLED = 20007        # 用户已禁用
    
    # 用户相关状态码 (21xxx)
    USER_NOT_FOUND = 21001       # 用户不存在
    USER_ALREADY_EXISTS = 21002  # 用户已存在
    USERNAME_EXISTS = 21003      # 用户名已存在
    EMAIL_EXISTS = 21004         # 邮箱已存在
    PHONE_EXISTS = 21005         # 手机号已存在
    
    # 设备相关状态码 (30xxx)
    DEVICE_NOT_FOUND = 30001     # 设备不存在
    DEVICE_ALREADY_EXISTS = 30002 # 设备已存在
    DEVICE_OFFLINE = 30003       # 设备离线
    DEVICE_IN_MAINTENANCE = 30004 # 设备维护中
    DEVICE_FAULT = 30005         # 设备故障
    DEVICE_BUSY = 30006          # 设备忙碌
    
    # 工单相关状态码 (40xxx)
    WORK_ORDER_NOT_FOUND = 40001   # 工单不存在
    WORK_ORDER_STATUS_ERROR = 40002 # 工单状态错误
    WORK_ORDER_ASSIGNED = 40003     # 工单已分配
    WORK_ORDER_COMPLETED = 40004    # 工单已完成
    WORK_ORDER_CANCELLED = 40005    # 工单已取消
    
    # 告警相关状态码 (50xxx)
    ALERT_NOT_FOUND = 50001      # 告警不存在
    ALERT_ALREADY_RESOLVED = 50002 # 告警已解决
    
    # 文件相关状态码 (60xxx)
    FILE_NOT_FOUND = 60001       # 文件不存在
    FILE_TOO_LARGE = 60002       # 文件过大
    FILE_TYPE_NOT_ALLOWED = 60003 # 文件类型不允许
    UPLOAD_FAILED = 60004        # 上传失败
    
    # MQTT相关状态码 (70xxx)
    MQTT_CONNECTION_FAILED = 70001 # MQTT连接失败
    MQTT_PUBLISH_FAILED = 70002    # MQTT发布失败
    MQTT_SUBSCRIBE_FAILED = 70003  # MQTT订阅失败


# 业务状态码消息映射
BUSINESS_CODE_MESSAGES = {
    # 通用消息
    BusinessCode.SUCCESS: "操作成功",
    BusinessCode.PARAM_ERROR: "参数错误",
    BusinessCode.DATA_NOT_FOUND: "数据不存在",
    BusinessCode.DATA_ALREADY_EXISTS: "数据已存在",
    BusinessCode.OPERATION_FAILED: "操作失败",
    
    # 认证相关消息
    BusinessCode.USER_NOT_LOGIN: "用户未登录",
    BusinessCode.PERMISSION_DENIED: "权限不足",
    BusinessCode.TOKEN_EXPIRED: "令牌已过期",
    BusinessCode.TOKEN_INVALID: "令牌无效",
    BusinessCode.LOGIN_FAILED: "登录失败",
    BusinessCode.PASSWORD_ERROR: "密码错误",
    BusinessCode.USER_DISABLED: "用户已禁用",
    
    # 用户相关消息
    BusinessCode.USER_NOT_FOUND: "用户不存在",
    BusinessCode.USER_ALREADY_EXISTS: "用户已存在",
    BusinessCode.USERNAME_EXISTS: "用户名已存在",
    BusinessCode.EMAIL_EXISTS: "邮箱已存在",
    BusinessCode.PHONE_EXISTS: "手机号已存在",
    
    # 设备相关消息
    BusinessCode.DEVICE_NOT_FOUND: "设备不存在",
    BusinessCode.DEVICE_ALREADY_EXISTS: "设备已存在",
    BusinessCode.DEVICE_OFFLINE: "设备离线",
    BusinessCode.DEVICE_IN_MAINTENANCE: "设备维护中",
    BusinessCode.DEVICE_FAULT: "设备故障",
    BusinessCode.DEVICE_BUSY: "设备忙碌",
    
    # 工单相关消息
    BusinessCode.WORK_ORDER_NOT_FOUND: "工单不存在",
    BusinessCode.WORK_ORDER_STATUS_ERROR: "工单状态错误",
    BusinessCode.WORK_ORDER_ASSIGNED: "工单已分配",
    BusinessCode.WORK_ORDER_COMPLETED: "工单已完成",
    BusinessCode.WORK_ORDER_CANCELLED: "工单已取消",
    
    # 告警相关消息
    BusinessCode.ALERT_NOT_FOUND: "告警不存在",
    BusinessCode.ALERT_ALREADY_RESOLVED: "告警已解决",
    
    # 文件相关消息
    BusinessCode.FILE_NOT_FOUND: "文件不存在",
    BusinessCode.FILE_TOO_LARGE: "文件过大",
    BusinessCode.FILE_TYPE_NOT_ALLOWED: "文件类型不允许",
    BusinessCode.UPLOAD_FAILED: "上传失败",
    
    # MQTT相关消息
    BusinessCode.MQTT_CONNECTION_FAILED: "MQTT连接失败",
    BusinessCode.MQTT_PUBLISH_FAILED: "MQTT发布失败",
    BusinessCode.MQTT_SUBSCRIBE_FAILED: "MQTT订阅失败"
}